package com.molichuxing.gateway.bff.user.convertor;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.molichuxing.gateway.bff.user.entity.response.AccountVo;
import com.molichuxing.gateway.bff.user.entity.response.UserVo;
import com.molichuxing.services.business.dto.response.UserBizDto;
import com.molichuxing.services.infrastructure.dto.response.response.AccountDto;

/**
 * 
 * @author liyg
 * 数据转换类
 * 2019-08-16
 *
 */
public class Convert {
	
	public static UserVo toUserVo(UserBizDto bizDto) {
		UserVo vo=null;
		if(null != bizDto) {
			vo=new UserVo();
			BeanUtils.copyProperties(bizDto,vo);
			vo.setUserId(bizDto.getId());
		}
		return vo;
	}
	
	public static AccountVo toAccountVo(AccountDto dto) {
		AccountVo vo=null;
		if(null != dto) {
			vo=new AccountVo();
			BeanUtils.copyProperties(dto,vo);
		}
		return vo;
	}
	
	public static List<AccountVo> toAccountVo(List<AccountDto> dtoList) {
		List<AccountVo> list = null;
		if(null != dtoList && dtoList.size() > 0) {
			list = new ArrayList<>();
			for (AccountDto dto : dtoList) {
				list.add(toAccountVo(dto));
			}
		}
		return list;
	}
}
